<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>添加商品</h1>
    <input type="text" v-model="product.title" placeholder="请输入商品名称"><br>
    <input type="text" v-model="product.price" placeholder="请输入商品价格"><br>
    <input type="text" v-model="product.num" placeholder="请输入商品库存"><br>
    <input type="button" value="添加" @click="add()">
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            product: {
                title: "",
                price: "",
                num: ""
            }
        },
        methods: {
            add(){
                axios.post("/add",v.product).then(function (response) {
                    alert("添加成功")
                    location.href="/"
                })
            }
        }
    })
</script>
</html>